package com.code516.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import com.code516.entity.StudentEntity;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface StudentDao {

	
	@Select(value = "SELECT * FROM stu_info WHERE stuMobile=#{stuMobile} ")
	public StudentEntity findByMobile(@Param("stuMobile") String stuMobile) throws Exception;
	
	@Insert(value = "insert into stu_info(stuName,nickname,stuTitle,stuSex,stuMobile,stuPass,idCard,stuLevel,isStudent,money,stuSchool,trainingSchool,stuGrade,stuAddtime,city,stuRemark,isUsed) values(#{studentEntity.stuName},#{studentEntity.nickname},#{studentEntity.stuTitle},#{studentEntity.stuSex},#{studentEntity.stuMobile},#{studentEntity.stuPass},#{studentEntity.idCard},#{studentEntity.stuLevel},#{studentEntity.isStudent},#{studentEntity.money},#{studentEntity.stuSchool},#{studentEntity.trainingSchool},#{studentEntity.stuGrade},#{studentEntity.stuAddtime},#{studentEntity.city},#{studentEntity.stuRemark},#{studentEntity.isUsed})")
	public int saveStudent(@Param("studentEntity")StudentEntity studentEntity) throws Exception;

	@Update(value = "update stu_info set stuPass=#{password} where stuMobile=#{stuMobile} ")
	public void updatePass(@Param("stuMobile") String stuMobile, @Param("password") String password) throws Exception;
	
	@Update(value = "update stu_info set stuName=#{studentEntity.stuName},nickname=#{studentEntity.nickname},stuSex=#{studentEntity.stuSex},birthday=#{studentEntity.birthday},stuPass=#{studentEntity.stuPass},city=#{studentEntity.city},stuRemark=#{studentEntity.stuRemark} where stuId=#{studentEntity.stuId}")
	public void saveUpdateStudent(@Param("studentEntity")StudentEntity studentEntity) throws Exception;
	
	@Select(value = "select * from stu_info where stuId=#{stuId} ")
	public StudentEntity findById(int stuId) throws Exception;
	
	
}
